//
//  ZXUserInfomation.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/4.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "ZXUserInfomation.h"

@implementation ZXUserInfomation
+ (instancetype)sharedManager{
    static id _instance;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        _instance = [[self alloc] init];
    });
    
    return _instance;
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}
-(void)setLoginModel:(ZXLoginModel *)loginModel{
    _loginModel = loginModel;
    self.userInfo = loginModel.result.firstObject;
    
    [self getUserInfoWithUSERID:self.userInfo.userId];
}
- (void)getUserInfoWithUSERID:(NSString *)USERID
{
    NSLog(@"USERID = %@",USERID);
    
    [[ZXHTTPManager sharedManager] getUserInfoWithUserId:USERID certNo:@"" completed:^(NSDictionary *jsonDict, NSError *error) {
        
        logError;
        
        NSLog(@"jsonDict = %@",jsonDict);
        
        if ([jsonDict[@"status"] isEqualToString:@"0"]) {
            //成功
            NSDictionary * dict = jsonDict[@"result"][0];
            self.userDetailInfo = [ZXUserDetailInfo mj_objectWithKeyValues:dict];
        }else{
            //失败
        }
    }];
}
-(void)setUserDetailInfo:(ZXUserDetailInfo *)userDetailInfo{
    _userDetailInfo = userDetailInfo;
    self.userInfo.tel = userDetailInfo.tel;
}
@end
